package com.three.lab.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.three.lab.R;
import com.three.lab.bean.AddressBean;

import java.util.List;

public class AddressListAdapter extends BaseQuickAdapter<AddressBean, BaseViewHolder> {

    public AddressListAdapter(@Nullable List<AddressBean> data) {
        super(R.layout.item_list_address, data);
    }

    public AddressListAdapter() {
        super(R.layout.item_list_address);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, AddressBean item) {
        helper.setText(R.id.tv_letter,"" + item.getName().substring(0,1))
        .setText(R.id.tv_name,item.getName())
        .setText(R.id.tv_phone,item.getPhone())
        .setText(R.id.tv_address,item.getProvince() + item.getCity() + item.getArea())
        .setText(R.id.tv_detail,item.getAddress())
        .setGone(R.id.tv_default,item.isDefault())
        .addOnClickListener(R.id.iv_edit);
    }
}
